Skip to content

fix(ui): fix invalid HTML structure in SideNavigation component tree#1792

Merged
franzheidl merged 5 commits into
mainfrom
franz-fix-sidenav-semantics-1791
Jun 24, 2026
Merged

fix(ui): fix invalid HTML structure in SideNavigation component tree#1792
franzheidl merged 5 commits into
mainfrom
franz-fix-sidenav-semantics-1791

Conversation

@franzheidl

@franzheidl franzheidl commented Jun 23, 2026

Copy link
Copy Markdown
Member

The SideNavigation component tree was producing invalid HTML as per issue #1791:

SideNavigation renders a <ul> but its children (SideNavigationItem, SideNavigationGroup) were rendering <div> wrappers and React fragments instead of <li> elements. Direct children of a <ul> must be <li> elements; anything else violates the HTML spec and breaks assistive technology semantics.

A second related issue: when SideNavigationItem had nested children (expand/collapse), they were rendered as flat siblings after the item rather than inside a nested <ul>.

Changes

SideNavigationItem

  • Outer <div> replaced with <li> (with flex-col to stack the header row and the nested sub-list)
  • Nested children are now wrapped in a <ul> when expanded
  • children prop JSDoc updated to clarify primary use (nested items) vs. string fallback (label)

SideNavigationGroup

  • React fragment replaced with <li>
  • Children wrapped in a <ul> when expanded

Behavior change: SideNavigationGroup is top-level only

SideNavigationGroup previously consumed and incremented LevelContext, which caused its label and descendants to be indented based on nesting depth. As part of this PR, SideNavigationGroup no longer participates in LevelContext:

  • The group label gets no level-* class — groups always render flush with the navigation edge.
  • The group does not increment the level for its children — direct SideNavigationItem children render at level-1.

This reflects the intended use of SideNavigationGroup as a first-level grouping construct only. Nesting groups inside groups (or inside items) is not a supported pattern; use nested SideNavigationItems instead for hierarchical navigation.

Notes

  • No public API changes — all existing usage continues to work as before
  • The decision to auto-wrap nested children in <ul> (rather than require callers to pass one) was deliberate: children is already typed to ReactElement<SideNavigationItemProps>, so the component can safely wrap unconditionally with no risk of producing a <ul><ul> double-wrap. TypeScript enforces call-site correctness; the auto-wrap keeps the API clean and leak-free.
  • SideNavigationItem nesting inside SideNavigationItem is unaffected

Related Issues

Closes #1791 , #1787

Signed-off-by: Franz Heidl <f.heidl@sap.com>
@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 93fc172

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-24 15:03 UTC

@franzheidl franzheidl self-assigned this Jun 23, 2026
@franzheidl franzheidl added the ui-components All tasks related to juno-ui-components library label Jun 23, 2026
Signed-off-by: Franz Heidl <f.heidl@sap.com>
- remove Level context from SideNavigationGroup
- add top spacing to SideNavigationGroup (except for first-child)
- decrease font-size for -Group label

Signed-off-by: Franz Heidl <f.heidl@sap.com>
@franzheidl franzheidl requested a review from Copilot June 23, 2026 16:50
@franzheidl franzheidl marked this pull request as ready for review June 23, 2026 16:51
@franzheidl franzheidl requested a review from a team as a code owner June 23, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes invalid HTML list semantics in the SideNavigation component tree by ensuring that list containers (<ul>) contain proper list items (<li>) and that expandable nested items render inside nested <ul> elements, improving spec compliance and assistive-technology semantics.

Changes:

  • Updated SideNavigationItem to render a <li> root and wrap expanded nested items in a <ul>.
  • Updated SideNavigationGroup to render a <li> root and wrap expanded children in a <ul>.
  • Adjusted Storybook examples and added minor SideNavigation CSS updates related to groups.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
packages/ui-components/src/components/SideNavigationItem/SideNavigationItem.component.tsx Converts item wrapper to <li> and introduces nested <ul> for expanded children.
packages/ui-components/src/components/SideNavigationGroup/SideNavigationGroup.component.tsx Converts group wrapper to <li> and introduces nested <ul> for expanded children.
packages/ui-components/src/components/SideNavigationGroup/SideNavigationGroup.stories.tsx Updates group stories to reflect new rendering / nesting behavior.
packages/ui-components/src/components/SideNavigation/SideNavigation.stories.tsx Updates SideNavigation story examples to use the new group/item nesting patterns.
packages/ui-components/src/components/SideNavigation/sidenavigation.css Adds/adjusts group-related styling and comments.

Comment thread packages/ui-components/src/components/SideNavigation/sidenavigation.css Outdated
edda and others added 2 commits June 24, 2026 14:54
- Guard nested <ul> rendering on hasChildren so empty lists are not emitted
- Reset default list styling for all <ul>s inside .juno-sidenavigation
- Update stories description and fix typo in sidenavigation.css comment
- Rewrite stale level-* tests to match groups-are-top-level behavior
- Add regression tests asserting valid <ul>/<li> list semantics

Signed-off-by: Esther Schmitz <esther.schmitz@sap.com>
- add class to component
- fix test accrodingly

Signed-off-by: Franz Heidl <f.heidl@sap.com>
@franzheidl franzheidl merged commit efc6dcc into main Jun 24, 2026
24 checks passed
@franzheidl franzheidl deleted the franz-fix-sidenav-semantics-1791 branch June 24, 2026 15:03
edda added a commit that referenced this pull request Jun 24, 2026
Covers PR #1792, which was merged without a changeset.

Signed-off-by: Esther Schmitz <esther.schmitz@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui-components All tasks related to juno-ui-components library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task](ui): fix invalid HTML structure in SideNavigation, SideNavigationItem, and SideNavigationGroup

4 participants